﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CSharp.Libs.WPF;
using CSharp.Libs.Koc;
using AutoKoC.Models;
using System.Windows.Input;

namespace AutoKoC.ViewModels
{
    class OptionsViewModel : ViewModelBase
    {
        #region declarations
        private AppBase _AB = null;
        #endregion



        #region constructor / terminator
        public OptionsViewModel(
            AppBase AB)
        {
            _AB = AB;
        }

        ~OptionsViewModel()
        {
            if (_AB != null)
            {
                _AB = null;
            }
        }
        #endregion



        #region event handling
        #endregion



        #region private functions
        #endregion



        #region interface
        #region properties
        #region custom servers
        public String CustomServer1
        {
            get
            {
                return _AB.LAO.GetOption(constants.LAO_KOC_CUSTOM_SERVER_1);
            }
            set
            {
                Int32 intCustomServer = 0;
                Int32.TryParse(value, out intCustomServer);
                if (intCustomServer >= 0 && intCustomServer <= AutoKocReloader.MAX_SERVER_NUMBER)
                {
                    _AB.LAO.SetOption(constants.LAO_KOC_CUSTOM_SERVER_1, intCustomServer.ToString());
                }
            }
        }

        public String CustomServer2
        {
            get
            {
                return _AB.LAO.GetOption(constants.LAO_KOC_CUSTOM_SERVER_2);
            }
            set
            {
                Int32 intCustomServer = 0;
                Int32.TryParse(value, out intCustomServer);
                if (intCustomServer >= 0 && intCustomServer <= AutoKocReloader.MAX_SERVER_NUMBER)
                {
                    _AB.LAO.SetOption(constants.LAO_KOC_CUSTOM_SERVER_2, intCustomServer.ToString());
                }
            }
        }

        public String CustomServer3
        {
            get
            {
                return _AB.LAO.GetOption(constants.LAO_KOC_CUSTOM_SERVER_3);
            }
            set
            {
                Int32 intCustomServer = 0;
                Int32.TryParse(value, out intCustomServer);
                if (intCustomServer >= 0 && intCustomServer <= AutoKocReloader.MAX_SERVER_NUMBER)
                {
                    _AB.LAO.SetOption(constants.LAO_KOC_CUSTOM_SERVER_3, intCustomServer.ToString());
                }
            }
        }

        public String CustomServer4
        {
            get
            {
                return _AB.LAO.GetOption(constants.LAO_KOC_CUSTOM_SERVER_4);
            }
            set
            {
                Int32 intCustomServer = 0;
                Int32.TryParse(value, out intCustomServer);
                if (intCustomServer >= 0 && intCustomServer <= AutoKocReloader.MAX_SERVER_NUMBER)
                {
                    _AB.LAO.SetOption(constants.LAO_KOC_CUSTOM_SERVER_4, intCustomServer.ToString());
                }
            }
        }

        public String CustomServer5
        {
            get
            {
                return _AB.LAO.GetOption(constants.LAO_KOC_CUSTOM_SERVER_5);
            }
            set
            {
                Int32 intCustomServer = 0;
                Int32.TryParse(value, out intCustomServer);
                if (intCustomServer >= 0 && intCustomServer <= AutoKocReloader.MAX_SERVER_NUMBER)
                {
                    _AB.LAO.SetOption(constants.LAO_KOC_CUSTOM_SERVER_5, intCustomServer.ToString());
                }
            }
        }
        #endregion

        #endregion

        #region methods
        #endregion
        #endregion
    }
}
